package cn.jolyoulu.test.config;

import cn.jolyoulu.common.redis.lock.RedisLockKeyRule;
import cn.jolyoulu.common.redis.lock.RedisLockRuleManager;
import org.springframework.stereotype.Component;

import java.util.UUID;

/**
 * @Author LuZhouJin
 * @Date 2023/5/31
 */
@Component
public class TestRedisLockKeyRule implements RedisLockKeyRule {

    public TestRedisLockKeyRule(RedisLockRuleManager redisLockRuleManager) {
        redisLockRuleManager.add(this);
    }

    @Override
    public String getKey(String annotationArg, Object[] methodArg) {
        return "TestRedisLockKeyRule:" + annotationArg + ":" + UUID.randomUUID().toString();
    }

    @Override
    public void LockFailure() {
        throw new RuntimeException("TestRedisLockKeyRule");
    }
}
